define("www_logon", ["home"], function (home) {
    var Logon = function () {
        this.__name = "Logon", this.box = $(".logon-body"), this.spanTips = $("<span />")
    };
    return Logon.prototype = {
        constructor: Logon, tabsChange: function () {
            var e = this;
            e.box.on("click", "[data-tab-for]", function () {
                var e = $("[data-tab-for]"), o = $(".tab-box"), i = "#" + $(this).data("tab-for");
                e.removeClass("active"), $(this).addClass("active"), $(o).addClass("hide"), $(i).removeClass("hide"), home._vCode($(".mail-logon #img_vcode")), home._vCode($(".logon-form #img_vcode")), $("input:not([type=button])").val(""), home._input_check_tips("", $("input"))
            })
        }, mailLogonForm: function () {
            function e() {
                function e() {
                    return !!home._check_mail(r, !0) && (!!home._check_name(c, !0) && (!!home._check_password(h, !0) && (!!home._check_password2(h, s, !0) && (!!a.val() || (home._input_check_tips(null, a, "请输入验证码"), !1)))))
                }

                var o, d, _ = e();
                _ && (i.removeErrorClass("#mail_logon input"), o = n.find(".form-button .form-tips"), o.hide(), h.val(CryptoJS.SHA1(h.val())), d = $(".mail-logon .btn-logon"), d.html("跳转中...").attr("disabled", !0), $.ajax({
                    url: page.hash_create,
                    type: "post",
                    data: {
                        from: t.val(),
                        email: r.val(),
                        name: c.val(),
                        pwd: h.val(),
                        cpwd: s.val(),
                        verifyCode: a.val(),
                        gender: $("#mailMale")[0].checked ? 1 : $("#mailFemale")[0].checked ? 2 : 0
                    },
                    success: function (e) {
                        return o.hide(), e.length > 0 ? (d.html("注册").attr("disabled", !1), "验证码错误" == e ? (a.addClass("error").val("").focus(), home._vCode(u), home._input_check_tips(null, a, "验证码错误"), !1) : void home._input_check_tips(null, d, e)) : (location.href = page.successRegister + "?email=" + r.val(), !1)
                    }
                }))
            }

            function o() {
                n.on("keyup", "input", function () {
                    var e = $(this);
                    home._input_check_tips(e.val(), e, "不能为空")
                }), n.on("keyup blur", "input[id='userMail']", function () {
                    $(this);
                    home._check_mail(r)
                }), n.on("keyup", "input[id='userName'],input[id=userPassword],input[id=confirmPwd]", function () {
                    var e = $(this);
                    home._input_check_tips(e.val(), e)
                }), n.on("blur", "input[id='userName']", function () {
                    var e = $(this);
                    home._check_name(e)
                }), n.on("blur", "input[id='userPassword']", function () {
                    var e = $(this);
                    home._check_password(e)
                }), n.on("blur", "input[id='confirmPwd']", function () {
                    var e = $(this), o = $(this).parent().parent().prev().find("#userPassword");
                    home._check_password2(o, e)
                }), n.on("blur", "input[id='vCode']", function () {
                    var e = $(this);
                    if (!e.val()) return home._input_check_tips(null, a, "请输入验证码"), !1
                })
            }

            var i = this, n = $(".mail-logon"), t = n.find("input[id='from']"), r = n.find("input[id='userMail']"),
                c = n.find("input[id='userName']"), h = n.find("input[id='userPassword']"),
                s = n.find("input[id='confirmPwd']"), a = n.find("input[id='vCode']"),
                u = n.find("img[id='img_vcode']");
            i.box.on("click", ".mail-logon .btn-logon", function () {
                e()
            }), n.on("keyup", "input", function (o) {
                return 13 === o.keyCode ? (e(), !1) : void home._input_check_tips("", $(this), null)
            }), o(), i._codeRefreshForMail()
        }, phoneLogonForm: function () {
            function regFormSubmit() {
                function submit_before_check() {
                    return !!home._check_phone(iPhone, !0) && (!!home._check_name(iName, !0) && (!!home._check_password(iPassword, !0) && (!!home._check_password2(iPassword, confirmPwd, !0) && (iVCode.val() ? !!iPhoneVode.val() || (home._input_check_tips(null, iPhoneVode, "请输入短信验证码", !0), !1) : (home._input_check_tips(null, iVCode, "请输入验证码", !0), !1)))))
                }

                var iFormTips, btn, returnVal = submit_before_check();
                returnVal && (_this.removeErrorClass("#phone_logon input"), iFormTips = iForm.find(".form-button .form-tips"), iFormTips.hide(), btn = $(".phone-logon .btn-logon"), btn.html("跳转中...").attr("disabled", !0), $.ajax({
                    url: page.quick_create,
                    type: "post",
                    data: {
                        from: iFrom.val(),
                        name: iName.val(),
                        pwd: iPassword.val(),
                        cpwd: confirmPwd.val(),
                        verifyCode: iVCode.val(),
                        phone: iPhone.val(),
                        phone_v_code: iPhoneVode.val(),
                        gender: $("#phone-male")[0].checked ? 1 : $("#phone-female")[0].checked ? 2 : 0
                    },
                    success: function (data) {
                        var json = eval("(" + data + ")");
                        if (json.success) return location.href = page.successRegister, !1;
                        switch (btn.html("注册").attr("disabled", !1), iFormTips.hide(), json.msg) {
                            case"phone_exist":
                                home._input_check_tips(null, iPhone, "该号码已存在！");
                                break;
                            case"phone_number_error":
                                home._input_check_tips(null, iPhone, "请确保你输入的是正确的手机号码！");
                                break;
                            case"phone_v_code_empty":
                                home._input_check_tips(null, iPhoneVode, "请输入正确的手机验证码");
                                break;
                            case"phone_v_code_error":
                                home._input_check_tips(null, iPhoneVode, "请输入正确的手机验证码");
                                break;
                            case"验证码错误":
                                home._input_check_tips(null, iVCode, "请输入正确的图片验证码");
                                break;
                            default:
                                json.msg.indexOf("昵称长度") > -1 || json.msg.indexOf("不允许重名") > -1 ? home._input_check_tips(null, iName, json.msg) : home._input_check_tips(null, btn, json.msg)
                        }
                    }
                }))
            }

            function input_check() {
                iForm.on("keyup", "input", function () {
                    var e = $(this);
                    home._input_check_tips(e.val(), e, "不能为空")
                }), iForm.on("keyup blur", "input[id='userPhone']", function () {
                    home._check_phone(iPhone)
                }), iForm.on("keyup", "input[id='userName'],input[id=userPassword],input[id=confirmPwd]", function () {
                    var e = $(this);
                    home._input_check_tips(e.val(), e)
                }), iForm.on("blur", "input[id='userName']", function () {
                    var e = $(this);
                    home._check_name(e)
                }), iForm.on("blur", "input[id='userPassword']", function () {
                    var e = $(this);
                    home._check_password(e)
                }), iForm.on("blur", "input[id='confirmPwd']", function () {
                    var e = $(this), o = $(this).parent().parent().prev().find("#userPassword");
                    home._check_password2(o, e)
                }), iForm.on("blur", "input[id='vCode']", function () {
                    var e = $(this);
                    if (!e.val()) return home._input_check_tips(null, iVCode, "请输入验证码"), !1
                }), iForm.on("blur", "input[id='phoneVcode']", function () {
                    var e = $(this);
                    if (!e.val()) return home._input_check_tips(null, iPhoneVode, "请输入短信验证码"), !1
                })
            }

            var _this = this, iForm = $(".phone-logon"), iFrom = iForm.find("input[id='from']"),
                iPhone = iForm.find("input[id='userPhone']"), iPhoneVode = iForm.find("input[id='phoneVcode']"),
                iName = iForm.find("input[id='userName']"), iPassword = iForm.find("input[id='userPassword']"),
                confirmPwd = iForm.find("input[id='confirmPwd']"), iVCode = iForm.find("input[id='vCode']"),
                imgCode = iForm.find("img[id='img_vcode']"), returnVal = !1;
            _this.box.on("click", ".phone-logon .btn-logon", function () {
                regFormSubmit()
            }), iForm.on("keyup", "input", function (e) {
                return 13 === e.keyCode ? (regFormSubmit(), !1) : void home._input_check_tips("", $(this), null)
            }), input_check(), _this.box.on("click", ".phone-logon .send-phone-vcode", function () {
                $(this);
                _this._send_phone_vcode()
            }), _this._codeRefreshForPhone()
        }, removeErrorClass: function (e) {
            $(e).each(function (e, o) {
                var i = $(this);
                home._input_check_tips(i.val(), i, "不能为空")
            })
        }, _codeRefreshForMail: function () {
            var e = this;
            e.box.on("click", ".mail-logon .v-code-img", function () {
                var e = $(".mail-logon img[id='img_vcode']");
                home._vCode(e)
            })
        }, _codeRefreshForPhone: function () {
            var e = this;
            e.box.on("click", ".phone-logon .v-code-img", function () {
                var e = $(".phone-logon img[id='img_vcode']");
                home._vCode(e)
            })
        }, _send_phone_vcode: function () {
            var _this = this, _sendPhoneCode = $(".phone-logon"), iPhone = _sendPhoneCode.find("input[id='userPhone']"),
                vCode = _sendPhoneCode.find("input[id='vCode']"), imgcode = _sendPhoneCode.find("img[id='img_vcode']");
            if (home._check_phone(iPhone)) {
                if (!vCode.val()) return home._input_check_tips(null, vCode, "请输入图片验证码", !0), !1;
                $.ajax({
                    type: "POST",
                    url: page.sendVerifyCodeForRegister,
                    data: {phoneNumber: iPhone.val(), verifyCode: vCode.val()},
                    success: function (data) {
                        switch (data.msg || (data = eval("(" + data + ")")), data.msg) {
                            case"短信发送成功":
                                home._countDown();
                                break;
                            case"fail":
                                home._input_check_tips(null, iPhone, "短信发送失败！");
                                break;
                            case"verifyCode_error":
                                home._input_check_tips(null, vCode, "图片验证码错误！", !0), vCode.val(""), home._vCode(imgcode);
                                break;
                            case"phone_exist":
                                home._input_check_tips(null, iPhone, "该号码已存在！", !0);
                                break;
                            case"iPhoneVode_number_error":
                                home._input_check_tips(null, iPhone, "请确保你输入的是正确的手机号码！", !0);
                                break;
                            case"not_allow_to_send":
                                home._input_check_tips(null, iPhone, "发送次数过多，暂时不可获取验证码！");
                                break;
                            case"phone_number_error":
                                home._input_check_tips(null, iPhone, "手机号码错误", !0);
                                break;
                            case"success":
                                home._countDown();
                                break;
                            default:
                                home._input_check_tips(null, iPhone, data.msg, !0)
                        }
                    },
                    dataType: "json"
                })
            }
        }, register: function () {
            this.tabsChange(), this.mailLogonForm(), this.phoneLogonForm()
        }
    }, Logon
});